home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / examples / chap05 / Motd.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-11-25  |  1.5 KB  |  45 lines

  1. import java.io.DataInputStream;
  2. import java.io.File;
  3. import java.io.FileInputStream;
  4. import vrml.BaseNode;
  5. import vrml.Browser;
  6. import vrml.Event;
  7. import vrml.node.Script;
  8.  
  9. public class Motd extends Script {
  10.    String myFile = "C:/tmp/motd";
  11.    // $FF: renamed from: b vrml.Browser
  12.    Browser field_0;
  13.    // $FF: renamed from: in java.io.DataInputStream
  14.    DataInputStream field_1;
  15.    String message;
  16.  
  17.    public void initialize() {
  18.       this.field_0 = ((BaseNode)this).getBrowser();
  19.    }
  20.  
  21.    public void processEvent(Event var1) {
  22.       File var2 = null;
  23.       if (var1.getName().equals("clicked")) {
  24.          try {
  25.             var2 = new File(this.myFile);
  26.             this.field_1 = new DataInputStream(new FileInputStream(var2));
  27.          } catch (Exception var5) {
  28.             this.field_0.setDescription("can not open file: " + this.myFile);
  29.             ((Throwable)var5).printStackTrace();
  30.          }
  31.  
  32.          try {
  33.             if (var2.exists()) {
  34.                this.message = this.field_1.readLine();
  35.                this.field_0.setDescription(this.message);
  36.             } else {
  37.                this.field_0.setDescription("file does not exists: " + this.myFile);
  38.             }
  39.          } catch (Exception var4) {
  40.             ((Throwable)var4).printStackTrace();
  41.          }
  42.       }
  43.    }
  44. }
  45.